package com.ruoyi.workbench.service.impl;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.workbench.domain.WorkDialog;
import com.ruoyi.workbench.mapper.WorkDialogMapper;
import com.ruoyi.workbench.service.WorkDialogService;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 催办(WorkDialog)表服务实现类
 *
 * @author makejava
 * @since 2024-07-06 19:52:45
 */
@Service("workDialogService")
public class WorkDialogServiceImpl implements WorkDialogService {
    @Resource
    private WorkDialogMapper workDialogDao;

    /**
     * 通过ID查询单条数据
     *
     * @param dialogId 主键
     * @return 实例对象
     */
    @Override
    public WorkDialog queryById(Integer dialogId) {
        return this.workDialogDao.queryById(dialogId);
    }



    /**
     * 新增数据
     *
     * @param workDialog 实例对象
     * @return 实例对象
     */
    @Override
    public WorkDialog insert(WorkDialog workDialog) {
        this.workDialogDao.insert(workDialog);
        return workDialog;
    }

    /**
     * 修改数据
     *
     * @param workDialog 实例对象
     * @return 实例对象
     */
    @Override
    public WorkDialog update(WorkDialog workDialog) {
        this.workDialogDao.update(workDialog);
        return this.queryById(workDialog.getDialogId());
    }

    /**
     * 通过主键删除数据
     *
     * @param dialogId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer dialogId) {
        return this.workDialogDao.deleteById(dialogId) > 0;
    }

    @Override
    public AjaxResult getMyDialog(Map<String, Object> params) {
        return AjaxResult.success(workDialogDao.getMatterByDialogUserId(SecurityUtils.getUserId().intValue()));
    }
}
